﻿using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;

/// <summary>
/// Summary description for Rating
/// </summary>
public class RatingDAL
{
    DatabaseAccess dba = new DatabaseAccess();

    public bool InsertRating(Rating objRating)
    {
        SqlParameter[] paramList = new SqlParameter[3];
        paramList[0] = new SqlParameter("@pd_id",SqlDbType.Int);
        paramList[0].Value = objRating.PdID;
        paramList[1] = new SqlParameter("@cus_id", SqlDbType.Int);
        paramList[1].Value = objRating.CusID;
        paramList[2] = new SqlParameter("@rating",SqlDbType.Int);
        paramList[2].Value = objRating.RatingPoint;
        return dba.executeUpdate("proc_InsertRating", paramList);
    }
    public DataTable GetRatingByID(int pdID,int cusID)
    {
        SqlParameter[] paramList = new SqlParameter[2];
        paramList[0] = new SqlParameter("@pd_id",SqlDbType.Int);
        paramList[0].Value = pdID;
        paramList[1] = new SqlParameter("@cus_id",SqlDbType.Int);
        paramList[1].Value = cusID;
        return dba.executeSelect("proc_GetRating", paramList);
    }
    public DataTable GetTotalRatingByPDID(int pdID)
    { 
        SqlParameter[] paramList = new SqlParameter[1];
        paramList[0] = new SqlParameter("@pd_id",SqlDbType.Int);
        paramList[0].Value = pdID;
        return dba.executeSelect("proc_GetTotalRatingByPDID", paramList);
    }
        public DataTable GetSumPointByPDID(int pdID)
    { 
        SqlParameter[] paramList = new SqlParameter[1];
        paramList[0] = new SqlParameter("@pd_id",SqlDbType.Int);
        paramList[0].Value = pdID;
        return dba.executeSelect("proc_GetSumPointByPDID", paramList);
    }
	public RatingDAL()
	{
		//
		// TODO: Add constructor logic here
		//
	}
}
